/**
 * 题目1
 */
console.log("=========== 题目1 ===========");
var foo = function () {
    console.log("foo1")
}
foo()

var foo = function () {
    console.log("foo2")
}
foo()


function foo() {
    console.log("foo3")
}
foo()


function foo() {
    console.log("foo4")
}
foo()

/** 输出
 * foo1
 * foo2
 * foo2
 * foo2
 */

///////////////////////////////////////////////////
/**
 * 题目2
 */
console.log("=========== 题目2 ===========");
// 1
console.log("1", a, b)
var a = 12, b = '林一一';
function foo1() {
    // 2
    console.log("2", a, b)
    // 3
    var a = b = 13
    // var b = 13
    // var a = 13;
    // var b = 13
    console.log("3", a, b)
    
}
foo1()
console.log("4", a, b)

/**
 * 输出：
 * undefined undefined
 * undefined "林一一"
 * 13 13
 * 12 13
 */


///////////////////////////////////////////////////
/**
 * 题目3
 */
console.log("=========== 题目3 ===========");
a = 2
function foo3() {
    var a = 12;
    b = '林一一'
    // console.log('b' in window)
    console.log(a, b)
}

foo3()
console.log(b)
console.log(a)

/**
 * 输出：
    true
    12 "林一一"
    林一一
    2
 *
 */ 

///////////////////////////////////////////////////
/**
* 题目4
*/
console.log("=========== 题目4 ===========");
fn();
// console.log(v1);
// console.log(v2);
// console.log(v3);
function fn() {
    var v1 = v2 = v3 = 2019;
    console.log("v1", v1);
    console.log(v2);
    console.log(v3);
}
/**
 * 输出：
 * 2019
 * 2019
 * 2019
 * ReferenceError: v1 is not defined
 */


///////////////////////////////////////////////////
/**
* 题目5
*/
console.log("=========== 题目5 ===========");
console.log(aa) // undefined
var aa = '林一一'
if (false) {
    var aa = '林一一'
}
console.log("aa", aa) // 林一一


console.log("=========== 题目6 ===========");
// console.log(print())    // == window.print()
if (true) {
    function print1() {
        console.log('林一一')
    }
}
print1()
// console.log(print())

console.log("=========== 题目7 ===========");
zc = 'asdf'
console.log(zc);
if (false) {
    var zc = 'zc';
    test()
    console.log("1111111");
    function test() {
        console.log("test");
    }
}
console.log(zc);
// test();



console.log("=========== 题目8 ===========");
/**
 * 题目8
 */
console.log(eight);
var eight = 1;
function eight() {
    console.log(1);
}

// 或

console.log(eight);
function eight() {
    console.log(1);
}
var eight = 1;


console.log("=========== 题目9 ===========");
/**
 * 题目9
 */
let x = 0, y = 0;
function func(x) {
    func = function fn2(y) {
        console.log(x, y)
        console.log(++x + y)
    }
    console.log('a', x++)
}
func(1); // a, 1
func(2); // 2, 2   5

